home *** CD-ROM | disk | FTP | other *** search
- /*
- * Program to do the MegaMorphic Computing and Consulting
- * corporate report chart for 1985 using VDI.
- */
-
- #define MIN(A,B) (A)<(B) ? (A) : (B)
-
- #define BLACK 0
- #define WHITE 1
- #define RED 2
- #define GREEN 3
- #define BLUE 4
- #define YELLOW 5
- #define CYAN 6
- #define MAGENTA 7
-
- int scale;
-
- main()
- {
- int xy[100],
- i,
- height_req,
- line_length,
- char_width,
- cell_width,
- cell_height,
- title_size,
- hor_out,
- workout[66],
- device_handle,
- vert_out;
-
- static int workin[] = {1,1,RED,3,1,1,WHITE,0,0,GREEN,
- 1,'D','I','S','P','L','A','Y',' '};
- extern int scale;
- static int echo_xy[] = {0, 0};
- static int arrow[] = {130, 90, 136, 80, 130, 70,
- 130, 74, 126, 74, 126, 86,
- 130, 86, 130, 90};
- char input_string[2];
-
- /* initialize the device and put characteristics in workout */
- v_opnwk(workin,&device_handle,workout);
-
- /* create scaling based on aspect ratio of the device */
- scale = MIN(workout[51] / 240, workout[52] / 180);
-
- /* set a new character height */
- title_size = 16;
- vst_height(device_handle,to32k(title_size),
- &char_width,&cell_width,&cell_height);
-
- /* find out how long ruling is in NDC */
- line_length = to32k(240);
-
- /*
- * loop making sure that the title won't be
- * longer than the ruling
- */
- while (cell_width >= line_length / 36 &&
- title_size >= 2) {
-
- /* try a new height */
- vst_height(device_handle,
- to32k(--title_size),&char_width,
- &cell_width,&cell_height);
- }
-
- /* write out title */
- v_gtext(device_handle,to32k(10),to32k(163),
- "MegaMorphic Computing and Consulting");
-
- /* compute size for other text */
- height_req = (float)to32k(title_size) / 2;
-
- /* set character height smaller */
- vst_height(device_handle,height_req,
- &char_width,&cell_width,&cell_height);
-
- /* set connecting point to upper left corner of text */
- vst_alignment(device_handle,0,2,&hor_out,&vert_out);
-
- /* change text color */
- vst_color(device_handle,YELLOW);
-
- /* write out subtitle */
- v_gtext(device_handle,to32k(10),to32k(156),
- "1985 Corporate Report");
-
- /* create data to draw ruling */
- xy[0] = to32k(10); xy[1] = to32k(160);
- xy[2] = to32k(240); xy[3] = to32k(160);
-
- /* draw the ruling */
- v_pline(device_handle,2,xy);
-
- /* change text color */
- vst_color(device_handle,RED);
-
- /* write out pie label */
- v_gtext(device_handle,to32k(106),to32k(40),
- "Our");
- v_gtext(device_handle,to32k(106),
- (int)(to32k(40)-cell_height*1.5),
- "Share");
-
- /* set alignment to bottom left */
- vst_alignment(device_handle,0,0,&hor_out,&vert_out);
-
- /* change text color */
- vst_color(device_handle,BLUE);
-
- /* write out labels for bar chart */
- v_gtext(device_handle,to32k(172),to32k(40),
- "Support 46%");
-
- vst_color(device_handle,GREEN);
- v_gtext(device_handle,to32k(172),to32k(90),
- "Consulting 27%");
-
- vst_color(device_handle,RED);
- v_gtext(device_handle,to32k(172),to32k(120),
- "Systems 27%");
-
- /* set the interior style to solid */
- vsf_interior(device_handle,1);
-
- /* create coordinates for first bar */
- xy[0] = to32k(144); xy[1] = to32k(30);
- xy[2] = to32k(170); xy[3] = to32k(80);
-
- /* change fill color */
- vsf_color(device_handle,BLUE);
-
- /* draw bar */
- v_bar(device_handle,xy);
-
- /* set the interior style to empty */
- vsf_interior(device_handle,0);
-
- /* outline the bar */
- v_bar(device_handle,xy);
-
- /* modify for second bar */
- xy[1] = to32k(80); xy[3] = to32k(110);
-
- /* change fill color */
- vsf_color(device_handle,GREEN);
-
- /* set interior style to hatch */
- vsf_interior(device_handle,3);
-
- /* use narrow 45 degree lines */
- vsf_style(device_handle,1);
-
- /* draw second bar */
- v_bar(device_handle,xy);
-
- /* set the interior style to empty */
- vsf_interior(device_handle,0);
-
- /* outline the bar */
- v_bar(device_handle,xy);
-
- /* modify for third bar */
- xy[1] = to32k(110); xy[3] = to32k(140);
-
- /* change fill color */
- vsf_color(device_handle,RED);
-
- /* set interior style to hatch */
- vsf_interior(device_handle,3);
-
- /* use medium 45 degree lines */
- vsf_style(device_handle,2);
-
- /* draw third bar */
- v_bar(device_handle,xy);
-
- /* set interior style to empty */
- vsf_interior(device_handle,0);
-
- /* outline the bar */
- v_bar(device_handle,xy);
-
- /* set text alignment to top center */
- vst_alignment(device_handle,1,2,&hor_out,&vert_out);
-
- /* change text color */
- vst_color(device_handle,YELLOW);
-
- /* write out subtitles */
- v_gtext(device_handle,to32k(60),to32k(20),
- "Market Breakdown");
- v_gtext(device_handle,to32k(170),to32k(20),
- "Product Breakdown");
-
- /* change fill color */
- vsf_color(device_handle,GREEN);
-
- /* set fill interior to hatch */
- vsf_interior(device_handle,3);
-
- /* draw pie slice */
- v_pieslice(device_handle,to32k(60),to32k(80),
- to32k(50),450,3150);
-
- /* set interior style to empty */
- vsf_interior(device_handle,0);
-
- /* draw the outline of the big pie slice */
- v_pieslice(device_handle,to32k(60),to32k(80),
- to32k(50),450,3150);
-
- /* change fill color */
- vsf_color(device_handle,RED);
-
- /* set the interior style to solid */
- vsf_interior(device_handle,1);
-
- /* draw small pie slice */
- v_pieslice(device_handle,to32k(70),to32k(80),
- to32k(50),3150,450);
-
- /* set interior style to empty */
- vsf_interior(device_handle,0);
-
- /* outline the small pie slice */
- v_pieslice(device_handle,to32k(70),to32k(80),
- to32k(50),3150,450);
-
- /* change fill color */
- vsf_color(device_handle,YELLOW);
-
- /* set interior style to solid */
- vsf_interior(device_handle,1);
-
- /* for every one of the points in the arrow array */
- for (i=0;i<=15;i++) {
-
- /* transform the points */
- xy[i] = to32k(arrow[i]);
-
- }
-
- /* fill the arrow */
- v_fillarea(device_handle,8,xy);
-
- /* set the interior style to empty */
- vsf_interior(device_handle,0);
-
- /* outline the arrow */
- v_fillarea(device_handle,8,xy);
-
- /* wait for <CR> */
- vrq_string(device_handle,2,0,echo_xy,input_string);
-
- /* if first char is upper c do a hardcopy */
- if (input_string[0] == 'C') {
-
- /* call for hardcopy */
- v_hardcopy(device_handle);
- }
-
- /* clear the workstation */
- v_clrwk(device_handle);
-
- /* leave graphics mode */
- v_enter_cur(device_handle);
-
- /* close down the workstation */
- v_clswk(device_handle);
-
- }
-
- int to32k(world)
- int world;
-
- /*
- * function to take world coordinates
- * and translate them to NDC space.
- */
-
- {
- extern scale;
-
- return(world * scale);
- }